<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class C_File extends CI_Controller {

	function __construct()
 
    {
 
        parent::__construct();
 
        $this->load->helper('form');
 
        $this->load->helper('url');
 
    }  
	/**
	 * Index Page for this controller.
	 *
	 * Maps to the following URL
	 * 		http://example.com/index.php/welcome
	 *	- or -  
	 * 		http://example.com/index.php/welcome/index
	 *	- or -
	 * Since this controller is set as the default controller in 
	 * config/routes.php, it's displayed at http://example.com/
	 *
	 * So any other public methods not prefixed with an underscore will
	 * map to /index.php/welcome/<method_name>
	 * @see http://codeigniter.com/user_guide/general/urls.html
	 */
	public function index()
	{
	}
	//redirect(base_url().'c_form/dashbord', 'location', 302);
	public function delete_data($id = false)
	{
		if($id){
			$this->load->view('v_form');
		}
	}
	
	/**
	 * upload_file
	 *
	 */
	function upload_file($path)
	{		
		//////////////////////File//////////////////////////////////
		$file_element_name = 'userfile';
		
		//$this->gallery_path = str_replace('\\','/',realpath(APPPATH. '../files/pictures'));
		$config = array(
										//'file_name'    	=> time().'_'.'New Name',//pic name
										'allowed_types' 	=> 'jpeg|gif|jpg|png|bmp',
										'upload_path' 		=> './upload/'.$path,
										'max_size' 			=> 5120
									);
		
		$this->load->library('upload', $config);
	
		if(!$this->upload->do_upload($file_element_name)){
			echo 'Upload fail';
		}
		else
		{
			$image_data = $this->upload->data();
			echo $image_data['file_name'];
		}
	}
	
	/**
	 * Delete file
	 *
	 */
	function delete_file($path, $name)
	{
		//echo $this->input->post('picture');
		if ($name	!= '')
		{
			unlink('./upload/'.$path.'/'.$name);
		}
	}
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */